<!-- 关注页面： ty -->

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="/chat/css/mall.css" type="text/css" />
    <link rel="stylesheet" type="text/css" href="/chat/font_Icon/iconfont.css">
    <link rel="stylesheet" type="text/css" href="/chat/css/chat.css">
	<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
	<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
	<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
	
	<script type="text/javascript" >
// 加载本人关注列表
 $(function () {
	 flushFollow(); });
	 function flushFollow(){
	 $.ajax({
          url:"/chat/followList",
		  success: function (data) {		  
			  var context="";
			  for (var i = 0; i < data.length; i++) {				
				 var follow =  data[i];				  
				 context+= '<div class="chat-list-people">'
	               +'<div><a href="/chat/someoneinfo?uid='+follow.followed_id+'"><img src="'+follow.user_headimg+'" alt="头像" /></a></div>'
	              +' <div class="chat-name">'
	              +'     <p>'+follow.user_name+'</p></div>'	  
	              + '<input type="hidden"  id = "followed_id"  value="'+follow.followed_id+'"/>'
	              + '<input type="hidden"  id = "myname"  value="'+follow.myname+'"/>'
				  +' <div class="message-num" data-toggle="modal" data-target="#sendmessage" onclick="message('+follow.user_name+')">私信</div>'
	              +' <div class="message-num" onclick="unfollow('+follow.user_id+","+follow.followed_id+')" >已关注</div></div>'
				
			}
  				$(".chatBox-list").html(context);
		 	 }
		  });
	 }	 





</script>
	
	
</head>
<body>

<div class="chatContainer">
    
    
    <div class="chatBox" ref="chatBox">
         <div id="child_header" style="width:100%;height:50px">
        <div class="goback"><a href="javascript:history.back(-1)"><i></i></a></div>
        <div class="current_location"><span>关注列表</span></div>
    </div>
		
        <div class="chatBox-info">
						
            <div class="chatBox-list" ref="chatBoxlist">
				
                  <!-- 关注列表 -->
               
            </div>
</div>



        </div>
    </div>



<!-- 模态框（Modal） :  用户借阅记录      -->
<div class="modal fade" id="sendmessage" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title" id="myModalLabel">
					私信
				</h4>
			</div>
			<div class="modal-body">
				<textarea rows="3" cols="50" id="content">
				</textarea>				
				<button id="fasong" onclick="publishMessage()">Send</button>
			</div>
			
		</div><!-- /.modal-content -->
	</div><!-- /.modal -->
	


<script type="text/javascript" >

function unfollow(fanId,userId){       // 取消本人已关注的账号
	$.ajax({
          url:"/chat/delFollow",
          data:{
        	  "fanId":fanId,       
        	  "userId":userId     // 被关注者的id
          },
		  success: function (data) {
			  flushFollow();
		  }
	 });
}

	
	
	function personalDetails(data){  //(个人资料资料) 
		
	}
	

</script>


<script type="text/javascript" src="https://cdn-hangzhou.goeasy.io/goeasy.js"></script>
    <script type="text/javascript">      	 
	
        var goeasy = new GoEasy({
            appkey: 'BC-372aceece223476f86fe396ab9676c1c'
        });

             
 
        function publishMessage() {
            var publishMessage ="粉丝>"+document.getElementById("myname").value+
 ":"+document.getElementById("content").value;
            var channelname = document.getElementById("followed_id").value;

            goeasy.publish({
                channel: channelname,        // 你的关注者频道
                message: publishMessage,
                onFailed: function (error) {
                    alert(error.code + " : " + error.content);
                },
                onSuccess: function () {
                    document.getElementById("content").value = '';
 
                }
            });            
           
        }


    </script>
    




</body>
</html>
